package com.example.demo.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.example.demo.entity.Employee;
import org.apache.ibatis.annotations.*;

@Mapper
public interface EmployeeMapper extends BaseMapper<Employee> {
    // 新增员工
    @Insert("INSERT INTO employee(id,name,password,sex,phone,avatar,departmentid,department) VALUES (#{id}, #{name},#{password},#{sex},#{phone},#{avatar},#{departmentid},#{department})")
    void insert(@Param("id") int id,
                @Param("name") String name,
                @Param("password") String password,
                @Param("sex") String sex,
                @Param("phone") String phone,
                @Param("avatar") String avatar,
                @Param("departmentid") int departmentid,
                @Param("department") String department);
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insert(Employee employee);

    // 更新员工信息
    @Update("UPDATE employee SET id = #{id}, password = #{password} WHERE id = #{id}")
    int update(Employee employee);

    // 根据ID查询员工
    @Select("SELECT id,password FROM employee WHERE id = #{id}")
    Employee findById(Integer id);
}